package com.slipper.sfts.member;

import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.slipper.sfts.api.member.bo.MemberAccountBO;
import com.slipper.sfts.api.member.service.IMemberAccountSv;
import com.slipper.system.common.Constants;
import com.slipper.common.util.ResultUtil;

/**
 * 会员账号信息表
 * 
 * @date 2024-01-14 22:22:15
 */
@RestController
@RequestMapping("/memberAccount")
public class MemberAccountController {
    @Resource
    private IMemberAccountSv memberAccountSv;
    
    @PostMapping(value = "/queryBy")
    public String queryBy(@RequestBody MemberAccountBO bo) {
        if(bo.getId() == null || "".equals(bo.getId())) {
            return ResultUtil.toErrorJson("数据获取失败！");
        }
        return ResultUtil.toJson(memberAccountSv.queryBy(bo.getId()));
    }

    @PostMapping(value = "/queryList")
    public String queryList(@RequestBody MemberAccountBO bo) {
        return ResultUtil.toJson(memberAccountSv.queryList(bo));
    }
    
    @PostMapping(value = "/queryPage")
    public String queryPage(@RequestBody MemberAccountBO bo) {
        return ResultUtil.toJson(memberAccountSv.queryPage(bo));
    }

    @PostMapping(value = "/save")
    public String save(@RequestBody MemberAccountBO bo) {
        bo.setUpdateId(Constants.getCurrentUser().getEmployeeId());
        bo.setCreateId(Constants.getCurrentUser().getEmployeeId());
        return ResultUtil.toJson(memberAccountSv.save(bo));
    }

    @PostMapping(value = "/delete")
    public String delete(@RequestBody MemberAccountBO bo) {
        return ResultUtil.toJson(memberAccountSv.delete(bo));
    }
}
